package com.library.service.impl;

import com.library.bean.Book;
import com.library.mapper.BookMapper;
import com.library.service.BookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class BookServiceImpl implements BookService {

    @Resource
    private BookMapper bookMapper;

    @Override
    public int deleteBook(int bookId) {
        return bookMapper.deleteBook(bookId);
    }

    @Override
    public int updateBook(Book book) {
        return bookMapper.updateBook(book);
    }

    @Override
    public int insertBook(Book book) {
        if (bookMapper.selectBookByName(book.getBookName())==null){
            return bookMapper.insertBook(book);
        }
        return -1;
    }

    @Override
    public List<Book> selectBooksByCondition(Book book) {
        return bookMapper.findBooksByConditions(book);
    }
}
